package cn.xo68.demo.config;

import cn.xo68.boot.jwt.JwtTokenProperties;
import cn.xo68.boot.jwt.JwtTokenUtil;
import cn.xo68.core.crypto.EncryptHandle;
import cn.xo68.core.crypto.aes.AesEncryptHandleImpl;
import cn.xo68.core.crypto.des.DesEncryptHandleImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

@Configuration
public class JwtConfig {

    @Profile("aes")
    @Bean
    JwtTokenUtil jwtTokenUtil(JwtTokenProperties jwtTokenProperties){
        EncryptHandle encryptHandle=new AesEncryptHandleImpl();
        return new JwtTokenUtil(jwtTokenProperties,encryptHandle);
    }

    @Profile("des")
    @Bean
    JwtTokenUtil jwtTokenUtilDes(JwtTokenProperties jwtTokenProperties){
        EncryptHandle encryptHandle=new DesEncryptHandleImpl();
        return new JwtTokenUtil(jwtTokenProperties,encryptHandle);
    }
}
